// 打开网页创建【网页顶部加载进度条】
// 定义进度
var num = 0;
// 定义是否加载完成
var over = false;
// 开启一个定时器
var timer;
timer = setInterval(fun,10);
function fun(){
    // 获取加载条
    var nprogress = document.querySelector(".nprogress");
    if(num>=95 && !over) return;   //页面未加载完成，暂停操作进度条
    num++;
    if(nprogress){
        nprogress.style.width = num +"%";
    }else{
        nprogress = document.createElement("div");
        nprogress.className = "nprogress";
        nprogress.style.width = num + "%";
        nprogress.style.height = 5 + "px";
        nprogress.style.backgroundColor = "#f4de2c";
        nprogress.style.position = "fixed";
        nprogress.style.top = 0 ;
        document.body.appendChild(nprogress);

        // 新增加载小标识
        var nprogressRadius = document.createElement("div");
        nprogressRadius.className = "nprogressRadius";
        document.body.appendChild(nprogressRadius);

    }
    // 判断是否加载完成
    if(num >= 120){
        document.body.removeChild(nprogress);
        clearInterval(timer);
        document.body.removeChild(document.querySelector(".nprogressRadius"));
    }
};

window.addEventListener('load', function(){
    over = true
});
